package com.bodu.depress.controller;

import com.bodu.core.common.AbstractCommonController;
import com.bodu.core.entity.ParamReq;
import com.bodu.core.entity.result.PageResult;
import com.bodu.core.entity.result.Result;
import com.bodu.global.security.LoginUserUtil;
import com.bodu.global.annon.TraceLog;
import com.bodu.depress.entity.vo.DepressCollectStatissticsVo;
import com.bodu.depress.entity.request.DepressCollectStatissticsRequest;
import com.bodu.depress.service.DepressCollectStatissticsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* 统计数据 API
* @author Administrator
*/
@Api(tags = "统计数据 API")
@RestController
@RequestMapping("/depressCollectStatisstics")
public class DepressCollectStatissticsController extends AbstractCommonController<DepressCollectStatissticsService, DepressCollectStatissticsRequest, DepressCollectStatissticsVo> {

    @Autowired
    private DepressCollectStatissticsService depressCollectStatissticsService;

    @TraceLog()
    @GetMapping("{id}")
    public Result getModel(@PathVariable("id") Long id) {
        return super.getModel(depressCollectStatissticsService, id);
    }

    @TraceLog()
    @PostMapping
    @ApiOperation("保存统计数据")
    public Result<Integer> save(@RequestBody DepressCollectStatissticsRequest request) {
        request.setCreateUser(LoginUserUtil.getUserId());
        return super.save(depressCollectStatissticsService, request);
    }

    @TraceLog()
    @PutMapping
    @ApiOperation("更新统计数据")
    public Result<Integer> update(@RequestBody DepressCollectStatissticsRequest request) {
        request.setCreateUser(LoginUserUtil.getUserId());
        return super.update(depressCollectStatissticsService, request);
    }

    @TraceLog()
    @PostMapping("listPage")
    @ApiOperation("统计数据-查询")
    public Result<List<DepressCollectStatissticsVo>>listPage(@RequestBody ParamReq req) {
        return super.listPage(depressCollectStatissticsService, req);
    }

    @TraceLog()
    @PostMapping("countPage")
    @ApiOperation("统计数据-统计")
    public Result<Integer> countPage(@RequestBody ParamReq req) {
        return super.countPage(depressCollectStatissticsService, req);
    }

    @TraceLog()
    @PostMapping("page")
    @ApiOperation("统计数据-分页数据")
    public Result<PageResult> page(@RequestBody ParamReq<DepressCollectStatissticsRequest> req) {
        return super.page(depressCollectStatissticsService, req);
    }

    @TraceLog()
    @DeleteMapping("/delete/{id}")
    @ApiOperation("删除统计数据")
    public Result<Integer> delete(@PathVariable("id") Long id) {
        return super.delete(depressCollectStatissticsService, id);
    }

    @TraceLog()
    @ApiOperation("批量删除统计数据")
    @DeleteMapping("{ids}")
    public Result<Integer> batchDelete(List<Long> ids) {
        return super.batchDelete(depressCollectStatissticsService, ids);
    }

    @Override
    public Long getLoginUserId() {
        return LoginUserUtil.getUserId();
    }

}
